<template>
  <div class="parameter-input-outer">
    <div class="parameter-input-inner" ref="contentRef">
      <div class="parameter-input-container">
        <div class="page-title">计算参数输入页面</div>
        <div class="card-group">
          <!-- 酸轧PDO -->
          <div class="param-card">
            <div class="card-title">酸轧PDO</div>
            <el-form :inline="true" class="param-form">
              <el-form-item label="酸轧出口卷号">
                <el-input v-model="form.pdoExitCoilNo" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="热轧卷号">
                <el-input v-model="form.pdoHotCoilNo" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="钢种">
                <el-select v-model="form.pdoSteelGrade" placeholder="请选择">
                  <el-option label="DC01" value="DC01" />
                  <el-option label="SPHC" value="SPHC" />
                </el-select>
              </el-form-item>
              <el-form-item label="冷轧出口长度">
                <el-input v-model="form.pdoExitLength" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="冷轧出口宽度">
                <el-input v-model="form.pdoExitWidth" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="冷轧生产完成时间">
                <el-date-picker v-model="form.pdoFinishTime" type="datetime" placeholder="选择时间" />
              </el-form-item>
            </el-form>
          </div>
          <!-- 酸轧PDI -->
          <div class="param-card">
            <div class="card-title">酸轧PDI</div>
            <el-form :inline="true" class="param-form">
              <el-form-item label="冷轧出口厚度">
                <el-input v-model="form.pdiExitThickness" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="冷轧出口宽度">
                <el-input v-model="form.pdiExitWidth" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="生产代码">
                <el-input v-model="form.pdiProdCode" placeholder="请输入" />
              </el-form-item>
            </el-form>
          </div>
          <!-- 热轧PDI -->
          <div class="param-card">
            <div class="card-title">热轧PDI</div>
            <el-form :inline="true" class="param-form">
              <el-form-item label="C含量">
                <el-input v-model="form.hPdiC" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Si含量">
                <el-input v-model="form.hPdiSi" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Mn含量">
                <el-input v-model="form.hPdiMn" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P含量">
                <el-input v-model="form.hPdiP" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="S含量">
                <el-input v-model="form.hPdiS" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="晶粒尺寸">
                <el-input v-model="form.hPdiGrain" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Cu含量">
                <el-input v-model="form.hPdiCu" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Ni含量">
                <el-input v-model="form.hPdiNi" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Cr含量">
                <el-input v-model="form.hPdiCr" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Al含量">
                <el-input v-model="form.hPdiAl" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Nb含量">
                <el-input v-model="form.hPdiNb" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Ti含量">
                <el-input v-model="form.hPdiTi" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="Mo含量">
                <el-input v-model="form.hPdiMo" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="N含量">
                <el-input v-model="form.hPdiN" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="B含量">
                <el-input v-model="form.hPdiB" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="V含量">
                <el-input v-model="form.hPdiV" placeholder="请输入" />
              </el-form-item>
            </el-form>
          </div>
          <!-- 热轧PDO -->
          <div class="param-card">
            <div class="card-title">热轧PDO</div>
            <el-form :inline="true" class="param-form">
              <el-form-item label="rdt">
                <el-input v-model="form.hPdoRdt" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="fdt">
                <el-input v-model="form.hPdoFdt" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="ct">
                <el-input v-model="form.hPdoCt" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="热轧出口厚度">
                <el-input v-model="form.hPdoExitThickness" placeholder="请输入" />
              </el-form-item>
            </el-form>
          </div>
          <!-- 设定工艺 -->
          <div class="param-card">
            <div class="card-title">设定工艺</div>
            <el-form :inline="true" class="param-form">
              <el-form-item label="选速速度">
                <el-input v-model="form.techSpeed" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P4温度">
                <el-input v-model="form.techP4Temp" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P5温度">
                <el-input v-model="form.techP5Temp" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P6温度">
                <el-input v-model="form.techP6Temp" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P9温度">
                <el-input v-model="form.techP9Temp" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P10温度">
                <el-input v-model="form.techP10Temp" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P11温度">
                <el-input v-model="form.techP11Temp" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P12温度">
                <el-input v-model="form.techP12Temp" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="P13温度">
                <el-input v-model="form.techP13Temp" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="平整延伸率">
                <el-input v-model="form.techElongation" placeholder="请输入" />
              </el-form-item>
            </el-form>
          </div>
          <!-- 任务信息 -->
          <div class="param-card">
            <div class="card-title">任务信息</div>
            <el-form :inline="true" class="task-row">
              <el-form-item label="任务名称">
                <el-input v-model="form.taskName" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="提交人">
                <el-input v-model="form.submitter" placeholder="请输入" />
              </el-form-item>
              <el-form-item label="备注">
                <el-input v-model="form.remark" placeholder="请输入" />
              </el-form-item>
              <div class="footer-btns">
                <el-button type="primary" @click="handleSubmit">提交</el-button>
              </div>
            </el-form>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref, onMounted, onBeforeUnmount, nextTick } from 'vue'
const form = reactive({
  // 酸轧PDO
  pdoExitCoilNo: '',
  pdoHotCoilNo: '',
  pdoSteelGrade: '',
  pdoExitLength: '',
  pdoExitWidth: '',
  pdoFinishTime: '',
  // 酸轧PDI
  pdiExitThickness: '',
  pdiExitWidth: '',
  pdiProdCode: '',
  // 热轧PDI
  hPdiC: '', hPdiSi: '', hPdiMn: '', hPdiP: '', hPdiS: '', hPdiGrain: '',
  hPdiCu: '', hPdiNi: '', hPdiCr: '', hPdiAl: '', hPdiNb: '', hPdiTi: '',
  hPdiMo: '', hPdiN: '', hPdiB: '', hPdiV: '',
  // 热轧PDO
  hPdoRdt: '', hPdoFdt: '', hPdoCt: '', hPdoExitThickness: '',
  // 设定工艺
  techSpeed: '', techP4Temp: '', techP5Temp: '', techP6Temp: '', techP9Temp: '',
  techP10Temp: '', techP11Temp: '', techP12Temp: '', techP13Temp: '', techElongation: '',
  // 任务信息
  taskName: '', submitter: '', remark: ''
})
function handleSubmit() {
  // 校验并提交逻辑
  // 这里只做简单打印
  console.log('提交参数：', JSON.parse(JSON.stringify(form)))
}

const contentRef = ref<HTMLElement | null>(null)
function resizeContent() {
  nextTick(() => {
    const outer = document.querySelector('.parameter-input-outer') as HTMLElement
    const inner = contentRef.value
    if (outer && inner) {
      const scale = Math.min(
        outer.clientHeight / inner.scrollHeight,
        outer.clientWidth / inner.scrollWidth,
        1
      )
      inner.style.transform = `scale(${scale})`
      inner.style.marginTop = scale < 1 ? `${(outer.clientHeight - inner.scrollHeight * scale) / 2}px` : '0'
    }
  })
}
onMounted(() => {
  window.addEventListener('resize', resizeContent)
  resizeContent()
})
onBeforeUnmount(() => {
  window.removeEventListener('resize', resizeContent)
})
</script>

<style scoped>
.parameter-input-outer {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(to top, #eaf1fb 0%, #2c69e8 100%);
}
.parameter-input-inner {
  transform-origin: top center;
  transition: transform 0.2s, margin-top 0.2s;
  width: 100%;
}
.parameter-input-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  min-width: 900px;
}
.page-title {
  flex-shrink: 0;
  text-align: center;
  font-size: 26px;
  color: #222;
  font-weight: 600;
  margin: 10px 0;
  letter-spacing: 1px;
}
.card-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding-bottom: 20px;
}
.param-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px #0001;
  padding: 16px 24px 8px 24px;
  margin-bottom: 0;
  width: 100%;
}
.card-title {
  font-size: 13px;
  color: #2c3e50;
  font-weight: 500;
  margin-bottom: 6px;
}
.param-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
  width: 100%;
}
.param-form :deep(.el-form-item) {
  margin-bottom: 8px !important;
  margin-right: 0 !important;
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 320px;
}
.param-form :deep(.el-form-item__label) {
  color: #666;
  font-size: 12px;
  min-width: 60px;
  padding-right: 4px;
}
.param-form :deep(.el-input__wrapper),
.param-form :deep(.el-select__wrapper),
.param-form :deep(.el-date-editor) {
  background: #fff !important;
  border: 1px solid #dbeafe !important;
  color: #222 !important;
  border-radius: 2px !important;
  height: 28px;
  font-size: 13px;
  min-width: 120px;
  max-width: 220px;
  width: 100%;
  box-shadow: none !important;
}
.param-form :deep(.el-input__inner) {
  height: 26px !important;
  font-size: 13px;
}
.footer-btns {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0;
  padding: 0 0 0 0;
  width: 100%;
}
.footer-btns .el-button {
  font-size: 15px;
  padding: 6px 32px;
  height: 36px;
  background-image: linear-gradient(90deg, #3a8dde 0%, #2c69e8 100%) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 18px !important;
  box-shadow: 0 2px 8px rgba(44,105,232,0.08);
  margin-left: 0;
}
.footer-btns .el-button:hover {
  background-image: linear-gradient(90deg, #2c69e8 0%, #3a8dde 100%) !important;
  box-shadow: 0 4px 16px rgba(44,105,232,0.18);
}
@media (min-width: 700px) {
  .task-row {
    display: flex;
    align-items: flex-end;
    width: 100%;
    gap: 16px;
  }
  .task-row .el-form-item {
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 320px;
    margin-bottom: 0 !important;
  }
  .task-row .footer-btns {
    flex: 0 0 160px;
    justify-content: flex-end;
    margin-left: auto;
    margin-bottom: 0;
    padding: 0;
  }
}
@media (max-width: 1200px) {
  .parameter-input-container {
    min-width: 0;
    width: 98vw;
  }
}
@media (max-width: 700px) {
  .param-form, .task-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .footer-btns {
    justify-content: center !important;
    width: 100%;
    margin-top: 10px;
  }
  .page-title {
    font-size: 22px;
    margin: 8px 0;
  }
}
</style> 